<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">

<h:body>
	<p:dialog id="modalCreatePassagero" header="Cadastro Passageiro" hideEffect="fade" resizable="false" minHeight="400" minWidth="665" widgetVar="popupCreatePassageiro" modal="true" style="position: absolute" height="400" width="665" closeOnEscape="true">
		<h:form id="formCadastraCliente">
			<p:messages autoUpdate="true" />
			<div align="center">

				<h:panelGrid columns="2" columnClasses="colunaEsquerda,colunaDireita">

					<p:outputLabel for="txtNome" value="Nome:" />
					<p:inputText id="txtNome" value="#{vendaVooMB.cliente.nome}" size="40" maxlength="40" required="true" requiredMessage="Campo Obrigatório" />


					<p:outputLabel for="txtCpf" value="CPF:" />
					<p:inputText mask="999.999.999-99" value="#{vendaVooMB.cliente.cpf}" id="txtCpf" size="11" maxlength="11" required="true" requiredMessage="Campo Obrigatório">
						<f:convertNumber />
					</p:inputText>

					<p:outputLabel for="txtEmail" value="E-Mail:" />
					<p:inputText id="txtEmail" value="#{vendaVooMB.cliente.email}" size="40" maxlength="40" required="true" requiredMessage="Campo Obrigatório" />

					<p:outputLabel for="txtFone" value="Fone:" />
					<p:inputText id="txtFone" value="#{vendaVooMB.cliente.fone}" size="20" maxlength="40" required="true" requiredMessage="Campo Obrigatório">
						<f:convertNumber />
					</p:inputText>

					<p:outputLabel for="txtCelular" value="Celular" />
					<p:inputText id="txtCelular" value="#{vendaVooMB.cliente.celular}" size="20" maxlength="40" required="true" requiredMessage="Campo Obrigatório">
						<f:convertNumber />
					</p:inputText>

					<p:outputLabel for="txtEstado" value="UF: " />
					<p:inputText id="txtEstado" value="#{vendaVooMB.cliente.endereco.estado.sigla}" size="2" maxlength="2" required="true" requiredMessage="Campo UF Obrigatório" />

					<p:outputLabel for="txtCidade" value="Cidade: " />
					<p:inputText id="txtCidade" value="#{vendaVooMB.cliente.endereco.cidade.descricao}" size="30" maxlength="30" required="true" requiredMessage="Campo Cidade Obrigatório" />

					<p:outputLabel for="txtLogradouro" value="Logradouro:" />
					<p:inputText id="txtLogradouro" value="#{vendaVooMB.cliente.endereco.logradouro}" size="40" maxlength="40" required="true" requiredMessage="Campo Logradouro Obrigatório" />

					<p:outputLabel for="txtCEP" value="CEP:" />
					<p:inputText id="txtCEP" value="#{vendaVooMB.cliente.endereco.cep}" size="8" maxlength="8" required="true" requiredMessage="Campo CEP Obrigatório" />
					
				</h:panelGrid>

			</div>
			<p:panel id="display" header="Assento Disponiveis">
				<p:dataTable id="listaAssentosDisponiveis" var="assento" paginator="true" rows="10" value="#{vendaVooMB.listaAssentosDisponivel}">

					<p:column style="text-align:center; width: 30%" rendered="true">
						<f:facet name="header">Código Assento</f:facet>
						<h:outputText value="#{assento.codigo}" />
					</p:column>

					<p:column style="text-align:center; width: 30%" rendered="true">
						<f:facet name="header">Classe Assento</f:facet>
						<p:graphicImage height="20px" style="border:0;" value="/images/imgClasseAssento/#{assento.classeAssento}.png" title="#{assento.classeAssento==1?'Primeira Classe':'Classe Economica'}" />
					</p:column>

					<p:column style="text-align:center; width: 30%" rendered="true">
						<f:facet name="header">Status Assento</f:facet>
						<p:graphicImage height="20px" style="border:0;" value="/images/imgStatusAssento/#{assento.statusAssento}.png" title="#{assento.statusAssento==0?'Assento Livre':'Assento Ocupado'}" />
					</p:column>

					<p:column rendered="#{vendaVooMB.itemSelecionado.assentoComprado.idVoo==0}">
					 
						<p:commandLink id="selecionarAssento" action="#{vendaVooMB.marcarAssentoComoOcupado}" update="listaAssentosDisponiveis" disabled="#{assento.statusAssento==1}">
							<p:graphicImage height="20px" style="border:0;" value="/images/assento.png" title="Selecionar Assento" />
							<f:setPropertyActionListener target="#{vendaVooMB.itemSelecionado.assentoComprado}" value="#{assento}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</p:panel>
			
			<p:commandButton id="btSalvar" action="#{vendaVooMB.addPassageiro}" value="Adicionar" update="@form :formListaPassageiros" />
			<p:commandButton type="reset" id="btReset" value="Limpar" update="@form :formListaPassageiros" />			
		</h:form>
	</p:dialog>
</h:body>
</html>
